package data;


/**
 * This class manages data, methods, and fields relevant to a Land Management
 * Organization (LMA).
 * This class extends User and implements Comparable.
 * 
 * @author Stephen Amos
 */
public class LMA extends User implements Comparable<LMA>{
	
	/**
	 * The name of this organization.
	 */
	private String organization;
	
	/**
	 * Constructs a new Land Management Agency (LMA) object based upon the
	 * parameters passed in.
	 * 
	 * @param organization The organization's name.
	 * @param username The organization's username for logging into the System.
	 * @param password The organization's password for logging into the System.
	 * @param phone The organization's phone number.
	 * @param email The organization's e-mail address.
	 */
	public LMA(String organization, String username, String password, String phone, String email) {
		super(username, password, phone, email);
		this.organization = organization;
	}
	
	/**
	 * Gets this organization's name.
	 * 
	 * @return The organization's name.
	 */
	public String getOrganization() {
		return organization;
	}

	/**
	 * Sets this organization's name based upon the parameter passed in.
	 * 
	 * @param organization The organization name to be set.
	 */
	public void setOrganization(String organization) {
		this.organization = organization;
	}
	
	/**
	 * Determines whether this LMA object is the same as another object
	 * passed in.
	 * 
	 * @param x The object to be tested for equivalency with this Scheduler.
	 * @return Returns true if, and only if this LMA object and the object
	 * passed in are the same.
	 */
	public boolean equals(Object x) {
		if (x != null && x instanceof LMA && this.username != null) {
			String temp = ((LMA) x).getUsername();
			if (temp != null && !temp.trim().equals("") && this.username.equalsIgnoreCase(temp)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * This method compares this current LMA object with another
	 * LMA object based upon the organization's organization name.
	 * 
	 * @param other_lma The LMA object to be compared to.
	 * @return 0 if the LMA objects have the same organization field,
	 * a negative value if the compared LMA is alphabetically higher,
	 * or a positive value if the compared LMA is alphabetically lower.
	 */
	public int compareTo(LMA other_lma) {
		return this.organization.compareTo(other_lma.getOrganization());
	}
	
	/**
	 * Returns a String containing all of a Land Management Agency's fields.
	 * 
	 * @return A string containing all of a Land Management Agency's fields.
	 */
	public String toString() {
		return organization + ",," + username + ",," + password + ",," + phone + ",," + email + "\n";
	}

}
